package com.knowledge.data.constants;

/**
 * @Author:gaofeng
 * @Description:响应前端CODE
 * @Date:Created in 13:07 2020/3/15
 * @Modified By :
 */
public enum RespCodeEnum {

    SUCCESS(1000, "SUCCESS"),
    FAILED(2000, "FAILED"),
    ERROR(3000, "ERROR"),
    LOGIN(4000, "请登录"),
    APP_TOKEN(5000, "授权失败");

    /**
     * 响应码
     */
    private int code;

    /**
     * 响应信息
     */
    private String msg;

    /**
     * 构造方法
     */
    RespCodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 通过指定code获取对应信息
     */
    public static String getMsgByCode(int code) {
        for (RespCodeEnum item : RespCodeEnum.values()) {
            if (item.code == code) {
                return item.msg;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
